package com.hengda.museumonline.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.hengda.museumonline.R;
import com.hengda.museumonline.entity.UinfoBean;
import com.hengda.museumonline.utils.GlideCircleTransform;
import com.hengda.museumonline.utils.UinfoUtil;

/**
 * @author：JFWU on 2016/10/20 20:06
 * @E-mail：jeffy12138@126.com
 */
public class PersonalActivity extends BaseActivity {
    private android.widget.ImageView avatar;
    private android.widget.TextView usernicename;
    private android.widget.TextView sex;
    private android.widget.TextView signature;
    private UinfoUtil uinfoUtil;
    private TextView area;
    private TextView birthday;
    private TextView job;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_personal);
        this.job = (TextView) findViewById(R.id.job);
        this.birthday = (TextView) findViewById(R.id.birthday);
        this.area = (TextView) findViewById(R.id.area);
        this.signature = (TextView) findViewById(R.id.signature);
        this.sex = (TextView) findViewById(R.id.sex);
        this.usernicename = (TextView) findViewById(R.id.user_nicename);
        this.avatar = (ImageView) findViewById(R.id.avatar);
        uinfoUtil = new UinfoUtil(PersonalActivity.this, spUtil.getToken());
        uinfoUtil.setOnUinfoListener(new UinfoUtil.OnUinfoListener() {
            @Override
            public void onUinfo(UinfoBean uinfoBean) {
                if (1 == uinfoBean.getStatus()) {
                    Glide.with(PersonalActivity.this).load(uinfoBean.getData().getAvatar()).transform(new GlideCircleTransform(PersonalActivity.this)).into(avatar);
                    usernicename.setText(uinfoBean.getData().getUser_nicename());
                    sex.setText(uinfoBean.getData().getSex());
                    signature.setText(uinfoBean.getData().getSignature());
                    area.setText(uinfoBean.getData().getCity() + uinfoBean.getData().getArea());
                    birthday.setText(uinfoBean.getData().getBirthday());
                    job.setText(uinfoBean.getData().getJob());
                }
            }
        });

    }
}
